package pages

import (
	"github.com/templui/templui/internal/ui/layouts"
	"github.com/templui/templui/internal/ui/modules"
	"github.com/templui/templui/internal/ui/showcase"
)

templ Tooltip() {
	@layouts.DocsLayout(
		"Tooltip",
		"A small pop-up box that appears when a user hovers over an element. Uses Popover with Floating UI under the hood.",
		[]modules.TableOfContentsItem{
			{
				ID:   "installation",
				Text: "Installation",
			},
			{
				Text: "Examples",
				ID:   "examples",
				Children: []modules.TableOfContentsItem{
					{
						Text: "Positions",
						ID:   "positions",
					},
				},
			},
			{
				ID:   "api",
				Text: "API Reference",
				Children: []modules.TableOfContentsItem{
					{
						ID:   "tooltip",
						Text: "Tooltip",
					},
					{
						ID:   "trigger",
						Text: "Trigger",
					},
					{
						ID:   "content",
						Text: "Content",
					},
				},
			},
		},
	) {
		@modules.PageWrapper(modules.PageWrapperProps{
			Name:        "Tooltip",
			Description: templ.Raw(`Small pop-up that appears on hover. Powered by <a href="/docs/components/popover" class="text-primary underline underline-offset-2 hover:opacity-80 transition-opacity">Popover</a> with <a href="https://floating-ui.com/" target="_blank" rel="noopener noreferrer" class="text-primary underline underline-offset-2 hover:opacity-80 transition-opacity">Floating UI</a>.`),
			Tailwind:    true,
			VanillaJS:   true,
			Breadcrumbs: modules.Breadcrumbs{
				Items: []modules.BreadcrumbItem{
					{
						Text: "Docs",
						Path: "/docs",
					},
					{
						Text: "Components",
						Path: "/docs/components",
					},
					{
						Text: "Tooltip",
					},
				},
			},
		}) {
			@modules.ExampleWrapper(modules.ExampleWrapperProps{
				ShowcaseFile:    showcase.TooltipDefault(),
				PreviewCodeFile: "tooltip_default.templ",
			})
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Installation",
				ID:    "installation",
			}) {
				@modules.ComponentUsage(modules.ComponentUsageProps{
					ComponentName: "tooltip",
					JSFiles:       []string{"popover"},
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Examples",
				ID:    "examples",
			}) {
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Positions",
					PreviewCodeFile: "tooltip_positions.templ",
					ShowcaseFile:    showcase.TooltipPositions(),
					ID:              "positions",
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "API Reference",
				ID:    "api",
			}) {
				@modules.APILegend()
				<div id="tooltip" class="mb-8">
					@modules.APITable(modules.APITableProps{
						Title:       "Tooltip",
						Description: "Root wrapper component for tooltip functionality.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "",
								Description: "Unique identifier for the tooltip wrapper.",
								Required:    false,
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "",
								Description: "Additional CSS classes to apply to the tooltip wrapper.",
								Required:    false,
							},
							{
								Name:        "Attributes",
								Type:        "templ.Attributes",
								Default:     "",
								Description: "Additional HTML attributes to apply to the tooltip wrapper.",
								Required:    false,
							},
						},
					})
				</div>
				<div id="trigger" class="mb-8">
					@modules.APITable(modules.APITableProps{
						Title:       "Trigger",
						Description: "Element that triggers the tooltip on hover.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "",
								Description: "Unique identifier for the trigger element.",
								Required:    false,
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "",
								Description: "Additional CSS classes to apply to the trigger.",
								Required:    false,
							},
							{
								Name:        "Attributes",
								Type:        "templ.Attributes",
								Default:     "",
								Description: "Additional HTML attributes to apply to the trigger element.",
								Required:    false,
							},
							{
								Name:        "For",
								Type:        "string",
								Default:     "",
								Description: "ID of the tooltip content this trigger controls.",
								Required:    true,
							},
						},
					})
				</div>
				<div id="content" class="mb-8">
					@modules.APITable(modules.APITableProps{
						Title:       "Content",
						Description: "Container for the tooltip content with positioning options.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "",
								Description: "Unique identifier for the content element.",
								Required:    true,
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "",
								Description: "Additional CSS classes to apply to the content. Default styling includes dark background.",
								Required:    false,
							},
							{
								Name:        "Attributes",
								Type:        "templ.Attributes",
								Default:     "",
								Description: "Additional HTML attributes to apply to the content element.",
								Required:    false,
							},
							{
								Name:        "ShowArrow",
								Type:        "bool",
								Default:     "false",
								Description: "Whether to show an arrow pointing to the trigger element.",
								Required:    false,
							},
							{
								Name:        "Position",
								Type:        "Position",
								Default:     "top",
								Description: "Position of the tooltip relative to trigger. Options: 'top', 'right', 'bottom', 'left'.",
								Required:    false,
							},
							{
								Name:        "HoverDelay",
								Type:        "int",
								Default:     "0",
								Description: "Delay in milliseconds before showing the tooltip on hover.",
								Required:    false,
							},
							{
								Name:        "HoverOutDelay",
								Type:        "int",
								Default:     "0",
								Description: "Delay in milliseconds before hiding the tooltip on hover out.",
								Required:    false,
							},
						},
					})
				</div>
			}
		}
	}
}
